import { VxeFormItemProps, VxeGridPropTypes } from '@gui-pkg/antdcomponents';
import { useModal } from '@gui-pkg/antdcomponents';

const [registerMapModal, { openModal: openMapModal }] = useModal();

export const columns: VxeGridPropTypes.Columns = [
  {
    title: '测站名称',
    field: 'stnm',
    align: 'center',
  },
  {
    title: '测站编码',
    field: 'stcd',
    align: 'center',
    fixed: 'left',
  },
  {
    title: '汛限水位(米)',
    field: 'xxLevel',
    align: 'center',
  },
  {
    title: '设计水位(米)',
    field: 'controlWaterLevel',
    align: 'center',
  },
  {
    title: '设计总库容(万立方米)',
    field: 'capacity',
    align: 'center',
  },
  {
    title: '坝顶高程(米)',
    field: 'dam',
    align: 'center',
  },
  {
    title: '下游防护对象',
    field: 'protectedTarget',
    align: 'center',
  },
  {
    title: '所在河流',
    field: 'river',
    align: 'center',
  },
  {
    title: '坝型',
    field: 'type',
    align: 'center',
  },
  {
    title: '管理责任人',
    field: 'userGl',
    align: 'center',
  },
  {
    title: '技术责任人',
    field: 'userJs',
    align: 'center',
  },
  {
    title: '行政责任人',
    field: 'userXz',
    align: 'center',
  },
  {
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
  },
];

export const searchFormSchema: VxeFormItemProps[] = [
  {
    field: 'keywords',
    title: '快速搜索',
    itemRender: {
      name: 'AInput',
    },
    span: 6,
  },
  {
    span: 18,
    align: 'right',
    className: '!pr-0',
    itemRender: {
      name: 'AButtonGroup',
      children: [
        {
          props: { type: 'primary', content: '查询', htmlType: 'submit' },
          attrs: { class: 'mr-2' },
        },
        { props: { type: 'default', htmlType: 'reset', content: '重置' } },
      ],
    },
  },
];

export const formSchema = [
  {
    field: 'stnm',
    label: '测站名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'stcd',
    label: '测站编码',
    required: true,
    component: 'Input',
  },
  {
    field: 'capacity',
    label: '设计总库容(万立方米)',
    component: 'InputNumber',
  },
  {
    field: 'controlWaterLevel',
    label: '设计水位(米)',
    component: 'InputNumber',
  },
  {
    field: 'dam',
    label: '坝顶高程(米)',
    component: 'InputNumber',
  },
  {
    field: 'jxLevel',
    label: '校核水位(米)',
    component: 'InputNumber',
  },
  {
    field: 'xxLevel',
    label: '汛限水位(米)',
    component: 'InputNumber',
  },
  {
    field: 'river',
    label: '所在河流',
    component: 'Input',
  },
  {
    field: 'protectedTarget',
    label: '下游防护对象',
    component: 'Input',
  },
  {
    field: 'type',
    label: '坝型',
    component: 'Input',
  },
  {
    field: 'userGl',
    label: '管理责任人',
    component: 'Input',
  },
  {
    field: 'userJs',
    label: '技术责任人',
    component: 'Input',
  },
  {
    field: 'userXz',
    label: '行政责任人',
    component: 'Input',
  },
  {
    field: 'lgtd',
    label: '经度',
    component: 'InputNumber',
    colProps: { span: 4 },
    componentProps: ({ formActionType }) => {
      return {
        placeholder: '输入经度',
        onClick: () => {
          openMapModal(true, { formActionType });
        },
      }
    },
  },
  {
    field: 'lttd',
    label: '纬度',
    component: 'InputNumber',
    componentProps: ({ formActionType }) => {
      return {
        placeholder: '输入纬度',
        onClick: () => {
          openMapModal(true, { formActionType });
        },
      }
    },
  },
];

export { registerMapModal };
